#Load dependencies
require(tidyverse)
require(data.table)
require(splitstackshape)
require(countrycode)
'%ni%' <- Negate('%in%')
setwd("~/covid_simulation")
source("~/covid_simulation/Rcode/Make_STMF_factors.R")
## Loading required package: ISOweek
## [1] "UK estimate being constructed from 3 entities"
## `summarise()` has grouped output by 'country', 'year', 'month', 'sex'. You can override using the `.groups` argument.
## [1] "UK estimates still need adjusting:  FALSE"

Take a look at these factors in comparsion

countries <- unique(factors.merged$country_name)

lapply(1:length(countries), function(z) {
  factors.merged %>%
  filter(country_name == countries[z]) %>%
  ggplot(aes(x = month)) + 
  geom_line(aes(y = current_adj_factor, color = "Covid")) +
  geom_line(aes(y = past_adj_factor, color = "Counterfactual")) +
  facet_grid(rows = vars(age), cols = vars(sex)) + 
  labs(x = "Month", y = "Factor", color = "Type", title = paste(countries[z], "Factors"))
})
## [[1]]

## 
## [[2]]

## 
## [[3]]

## 
## [[4]]

## 
## [[5]]

## 
## [[6]]

## 
## [[7]]

## 
## [[8]]

## 
## [[9]]

## 
## [[10]]

## 
## [[11]]

## 
## [[12]]

## 
## [[13]]

## 
## [[14]]

## 
## [[15]]

## 
## [[16]]

## 
## [[17]]

## 
## [[18]]

## 
## [[19]]

## 
## [[20]]

## 
## [[21]]

## 
## [[22]]

## 
## [[23]]

## 
## [[24]]

## 
## [[25]]

## 
## [[26]]

## 
## [[27]]

## 
## [[28]]

## 
## [[29]]

## 
## [[30]]

## 
## [[31]]

## 
## [[32]]

## 
## [[33]]

## 
## [[34]]